package com.wb.test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.wb.dao.*;
import com.wb.entity.*;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class demo {

        @Test
        public void testAddUser() throws Exception{
            /*ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-dao.xml");
            ObjectMapper objectMapper = new ObjectMapper();
            UserMapper mapper=(UserMapper) applicationContext.getBean("userMapper");
            User user =mapper.getUserById(1);
            String str = objectMapper.writeValueAsString(user);
            System.out.println(str);
            ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-dao.xml");
            BlogMapper blogMapper = (BlogMapper) applicationContext.getBean("blogMapper");
            Blog blog = new Blog();
            blog.setBlog_id(8);
            UserMapper userMapper=(UserMapper) applicationContext.getBean("userMapper");
            User user =userMapper.getUserById(2);
            System.out.println(user.getPhoto());*/

            ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-dao.xml");
            UserMapper user_Mapper=(UserMapper) applicationContext.getBean("userMapper");
            BlogMapper blog_Mapper=(BlogMapper) applicationContext.getBean("blogMapper");
            LikesMapper like_Mapper=(LikesMapper) applicationContext.getBean("likesMapper");
            PictureMapper picture_Mapper=(PictureMapper)applicationContext.getBean("pictureMapper");
            CommentMapper comment_Mapper=(CommentMapper)applicationContext.getBean("commentMapper");
            BindMapper bind_Mapper=(BindMapper)applicationContext.getBean("bindMapper");
            Bind bind=new Bind();
            bind.setUser_id(1);
            bind.setFollower_id(3);
            bind_Mapper.deleteBind(bind);
            System.out.println(bind.getUser_id() + "受关注度为" + user_Mapper.findAllFollowers(user_Mapper.getUserById(bind.getUser_id())).size());

        }



}
